gRPC 是由 Google 開發的高效能、開源的遠端程序調用 (RPC) 框架,可在不同環境中運行。以下是 gRPC 的主要屬性及其與 .NET 的對應關係:
在使用上都是有預設值不可為 null,如果需要可以為 null 的型態,要 Import wrappers.proto 使用
.NET 類型 | Protobuf 型別 | .NET 類型 | 已知型別包裝函式 | |
---|---|---|---|---|
double |
double |
bool? |
google.protobuf.BoolValue |
|
float |
float |
double? |
google.protobuf.DoubleValue |
|
int |
int32 |
float? |
google.protobuf.FloatValue |
|
long |
int64 |
int? |
google.protobuf.Int32Value |
|
uint |
uint32 |
long? |
google.protobuf.Int64Value |
|
ulong |
uint64 |
uint? |
google.protobuf.UInt32Value |
|
int |
sint32 |
ulong? |
google.protobuf.UInt64Value |
|
long |
sint64 |
string |
google.protobuf.StringValue |
|
uint |
fixed32 |
ByteString |
google.protobuf.BytesValue |
|
ulong |
fixed64 |
|||
int |
sfixed32 |
|||
long |
sfixed64 |
|||
bool |
bool |
|||
string |
string |
|||
ByteString |
bytes |
.NET 類型 | Protobuf 已知型別 |
---|---|
DateTimeOffset |
google.protobuf.Timestamp |
DateTime |
google.protobuf.Timestamp |
TimeSpan |
google.protobuf.Duration |
以上就是 gRPC 對應 .Net 的一些型別對應,在後面撰寫 .proto
檔的時候就會用上。